const UESR_UPDATE = 'UESR_UPDATE'
const UESR_NAME = 'UESR_NAME'


/*---------------- action ----------------*/

const initialState = {}

export function userUpdate(state = initialState, action) {
    switch (action.type) {
        case UESR_UPDATE:
            return action.data
        case UESR_NAME:
            return action.data
        default:
            return state
    }
}


/*---------------- reducer ----------------*/

export function city(data) {
    return {
        type: UESR_UPDATE,
        data
    }
}

// 添加延迟
export function addLoginAsync(data) {
    // thunk插件的作用，这里可以返回函数，
    return dispatch => {
        setTimeout(() => {
            // 异步结束后，手动执行dispatch
            dispatch(city(data))
        }, 2000)
    }
}